package cn.openea.perpartner.cms.web.mapper;

import cn.openea.perpartner.cms.web.entity.CmsCustomer;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.openea.perpartner.cms.web.dto.FavCommunityDto;
import cn.openea.perpartner.cms.web.dto.FavCustomerDto;
import cn.openea.perpartner.cms.web.entity.CmsCommunity;
import cn.openea.perpartner.cms.web.entity.CmsFavorites;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * (CmsFavorites)表数据库访问层
 *
 * @author Weird077
 * @since 2022-08-25 10:06:53
 */
@Repository
public interface CmsFavoritesMapper extends BaseMapper<CmsFavorites> {

    @Select("select a.fav_id,a.link_id, b.* ,timestampdiff(day ,b.updatetime,now()) as dateBetween from cms_favorites a ${ew.customSqlSegment}")
    List<FavCustomerDto> selectCustomerList(@Param("ew")QueryWrapper<CmsCustomer> wrapper);

    @Select("select a.fav_id,a.link_id, b.* ,timestampdiff(day ,b.update_time,now()) as dateBetween from cms_favorites a ${ew.customSqlSegment}")
    List<FavCommunityDto> selectCommunityList(@Param("ew") QueryWrapper<CmsCommunity> wrapper);
}

